<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=5,IE=9" ><![endif]-->
<!DOCTYPE html>
<html>

<head>
	<title>Grapheditor</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<link rel="stylesheet" type="text/css" href="styles/grapheditor.css">
	<link rel="stylesheet" type="text/css" href="./src/css/common.css" type="text/css">
	<link rel="stylesheet" type="text/css" href="./src/css/explorer.css" type="text/css">
	<link rel="stylesheet" href="./styles/layui.css" media="all">
	<link rel="stylesheet" href="./styles/admin.css" media="all">
	<script type="text/javascript" src="./js/layui.js"></script>
	<!-- <script type="text/javascript" src="../../layuiadmin/config.js"></script> -->
	<!-- </head> -->
	<!-- .layui-layer, .layui-laydate, .layui-laydate-list {
	background-color: rgba(13,81,157,.9) !important;
	} -->
	<script type="text/javascript">
		// Parses URL parameters. Supported parameters are:
		// - lang=xy: Specifies the language of the user interface.
		// - touch=1: Enables a touch-style user interface.
		// - storage=local: Enables HTML5 local storage.
		// - chrome=0: Chromeless mode.
		var urlParams = (function (url) {
			var result = new Object();
			var idx = url.lastIndexOf('?');

			if (idx > 0) {
				var params = url.substring(idx + 1).split('&');

				for (var i = 0; i < params.length; i++) {
					idx = params[i].indexOf('=');

					if (idx > 0) {
						result[params[i].substring(0, idx)] = params[i].substring(idx + 1);
					}
				}
			}

			return result;
		})(window.location.href);
		let IOT_GLOBAL_CONFIG = {};
		IOT_GLOBAL_CONFIG.BIZ_SERVICE_HOST = '/realtworules/';
		IOT_GLOBAL_CONFIG.MQTT_SERVICE_HOST = 'http://172.26.200.80:5675/ws';
		CONTEXT_PATH = '/iemp';
		VIEW_PATH = CONTEXT_PATH + '/view';
		// Default resources are included in grapheditor resources
		'resources';
		window.RESOURCE_BASE = "../../";//window.RESOURCE_BASE || window.RESOURCES_PATH + '/grapheditor';
		mxLoadResources = false;
		window.urlParams = window.urlParams || {};
		window.MAX_REQUEST_SIZE = 10485760;
		window.MAX_AREA = 15000 * 15000;
		window.BaseURL = IOT_GLOBAL_CONFIG.BIZ_SERVICE_HOST;
		window.BaseFrontURL = '../../../..' + VIEW_PATH + '/grapheditor';
		window.EXPORT_URL = window.BaseURL + 'iot-admin/draw/export';
		window.SAVE_URL = window.BaseURL + 'iot-admin/draw/save';
		window.OPEN_URL = window.BaseURL + 'iot-admin/draw/open';
		window.RESOURCES_PATH = 'resources';
		window.RESOURCE_BASE = window.RESOURCES_PATH + '/grapheditor';
		window.STENCIL_PATH = 'stencils';
		window.IMAGE_PATH = 'images';
		window.STYLE_PATH = 'styles';
		window.CSS_PATH = 'styles';
		window.OPEN_FORM = 'open.html';
		window.mxBasePath = 'src';
		window.mxLanguage = 'zh-cn';
		window.mxLanguages = 'zh-cn';
		window.SHAPES_PATH = window.mxBasePath + '/js/shape';
	</script>
	<script type="text/javascript" src="./js/jquery.min.js"></script>
	<script type="text/javascript" src="../public/constant/iotConstant.js"></script>
	<script type="text/javascript" src="./js/layer.js"></script>
	<script type="text/javascript" src="./js/Api.js"></script>
	<script type="text/javascript" src="./deflate/pako.min.js"></script>
	<script type="text/javascript" src="./deflate/base64.js"></script>
	<script type="text/javascript" src="./jscolor/jscolor.js"></script>
	<script type="text/javascript" src="./sanitizer/sanitizer.min.js"></script>*
	<script type="text/javascript" src="./src/js/mxClient.js"></script>
	<script type="text/javascript" src="./js/Dialogs.js"></script>
	<script type="text/javascript" src="./js/EditorUi.js"></script>
	<script type="text/javascript" src="./js/Editor.js"></script>
	<script type="text/javascript" src="./js/Sidebar.js"></script>
	<script type="text/javascript" src="./js/Graph.js"></script>
	<script type="text/javascript" src="./js/Format.js"></script>
	<script type="text/javascript" src="./js/Shapes.js"></script>
	<script type="text/javascript" src="./js/Actions.js"></script>
	<script type="text/javascript" src="./js/Menus.js"></script>
	<script type="text/javascript" src="./js/Toolbar.js"></script>
	<script type="text/javascript" src="../downloadXml.js"></script>
	<script type="text/javascript">

		function fake_click(obj) {
			var ev = document.createEvent("MouseEvents");
			ev.initMouseEvent(
				"click", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null
			);
			obj.dispatchEvent(ev);
		}

		function download(name, data) {
			var urlObject = window.URL || window.webkitURL || window;

			var downloadData = new Blob([data]);

			var save_link = document.createElementNS("http://www.w3.org/1999/xhtml", "a")
			save_link.href = urlObject.createObjectURL(downloadData);
			save_link.download = name;
			fake_click(save_link);
		}

		// Extends EditorUi to update I/O action states based on availability of backend
		(function () {
			var editorUiInit = EditorUi.prototype.init;

			EditorUi.prototype.init = function () {
				editorUiInit.apply(this, arguments);

				// this.actions.get('export').setEnabled(false);

				// Updates action states which require a backend
				// if (!Editor.useLocalStorage) {
				// 	mxUtils.post(OPEN_URL, '', mxUtils.bind(this, function (req) {
				// 		var enabled = req.getStatus() != 404;
				// 		// this.actions.get('open').setEnabled(enabled || Graph.fileSupport);
				// 		this.actions.get('import').setEnabled(enabled || Graph.fileSupport);
				// 		this.actions.get('save').setEnabled(enabled);
				// 		this.actions.get('saveAs').setEnabled(enabled);
				// 		this.actions.get('export').setEnabled(enabled);
				// 	}));
				// }
			};

			// Adds required resources (disables loading of fallback properties, this can only
			// be used if we know that all keys are defined in the language specific file)
			mxResources.loadDefaultBundle = false;
			var bundle = mxResources.getDefaultBundle(RESOURCE_BASE, mxLanguage) ||
				mxResources.getSpecialBundle(RESOURCE_BASE, mxLanguage);
			//
			// Fixes possible asynchronous requests
			mxUtils.getAll([bundle, STYLE_PATH + '/default.xml'], function (xhr) {
				// Adds bundle text to resources
				mxResources.parse(xhr[0].getText());

				// Configures the default graph theme
				var themes = new Object();
				themes[Graph.prototype.defaultThemeName] = xhr[1].getDocumentElement();

				// Main
				new EditorUi(new Editor(urlParams['chrome'] == '0', themes));
			}, function () {
				document.body.innerHTML = '<center style="margin-top:10%;">Error loading resource files. Please check browser console.</center>';
			});
		})();
	</script>
</head>

<body class="geEditor">
</body>

</html>